
var _path = '${path}';
//url:form add and edit jsp
var _formAddEditUrl="/admin123/coding/${classNameFirstWordLower}/add_edit.jsp";
//url:form add action
var _formAddAction="/admin123/coding/${classNameFirstWordLower}/${classNameFirstWordLower}Ajax_addData.action";
//url:form edit action
var _formEditAction="/admin123/coding/${classNameFirstWordLower}/${classNameFirstWordLower}Ajax_editData.action";
//url:form remove action
var _formRemoveAction="/admin123/coding/${classNameFirstWordLower}/${classNameFirstWordLower}Ajax_removeData.action";
//url:report
var _formReportAction="/admin123/coding/${classNameFirstWordLower}/add_edit.jsp";





var _keyRandom='${_keyRandom}';
//上个页面通过右击列表 传过来的 id和row; ps:右击模板x列，看模板列列表，自动加载列数，要传模板id找表名
var _prePageListRow = '${r"${"}paramValues.row[0]${r"}"}';
_prePageListRow = decodeURI(_prePageListRow);
var _prePageListId = '${r"${"}paramValues._id[0]${r"}"}';

//template table foreign key
var _foreignKey = '${templateTable.foreignKey}';
var _primaryKey = '${templateTable.primaryKey}';

//add dialog width and height
var _width4AddDialog = '${templateTable.width4AddDialog}';
var _height4AddDialog = '${templateTable.height4AddDialog}';
if(_width4AddDialog == '' || _width4AddDialog == '0')_width4AddDialog=800;
if(_height4AddDialog == '' || _height4AddDialog == '0')_height4AddDialog=400;
//dialog style, 取代上面的方法
var _isdialog4AddDialog = '${templateTable.isdialog4AddDialog}';
var _style4AddDialog = '${templateTable.style4AddDialog?trim}';
if(_style4AddDialog == '')_style4AddDialog='width:800px;height:400px';


/*
	hidden fileds when option has changed
	选择optionId时，filedList是要隐藏的域
	结构如下 ：
	var hiddenFileds = [
		{"optionId":"11","filedList":[{"text":"foreignkey"},{"text":"tablenamesql"}]},
		{"optionId":"12","filedList":[{"text":"tablenamehistorysql"},{"text":"sqlsum"}]}
	];
*/
var hiddenFileds = ${hiddenFiledsJson}



/**
	页面datagrid控件显示列元素：datagrid.columns
*/
var datagrid_columns = [${columnsTag.columns}]


/**
页面datagrid控件显示列元素：datagrid.frozenColumns
*/
var datagrid_frozenColumns = []
var jarrTmp = ${columnsTag.frozenColumns};
var jo = {
"formatter":function(value,rowData,rowIndex){
if(typeof(rowData.id) == 'undefined'){return '';};
var btn = '';
btn += '<a rowIndex=\"'+rowIndex+'\" class=\"button\" style=\"height:16px;\"  href=\"javascript:void(0)\">菜单<\/a>';
    return btn;
    },
    "field":"menuItem",
    "width":70,
    "title":"菜单列表",
    "align":"center",
    "hidden":false};
var jarr = [];
jarr.push(jo);
$.each(jarrTmp,function(index,value){
jarr.push(jarrTmp[index]);
})
datagrid_frozenColumns.push(jarr);


    /**
页面datagrid控件显示列元素：datagrid.toolbarBtns
*/
var datagrid_toolbarBtns = [];
${columnsTag.toolbarBtns.buttonInit}


/**
datagrid ，后面在condition.js中init了
*/
var datagrid={
	datagridId:"list",
	datagridUrl:"${classNameFirstWordLower}Ajax_queryListBySearch.action",
	datagridObj:{
		/*title:"查询列表",*/
		nowrap:true,
		autoRowHeight:false,
		fit:true,
		columns:datagrid_columns,//datasoure in data.js
		frozenColumns:datagrid_frozenColumns,
		toolbar:datagrid_toolbarBtns,
		rownumbers:true,
		showFooter:true,
		onRowContextMenu:onRowContextMenu
	}
};


var isFirstLoadSuccess = true;
datagrid.datagridObj.onLoadSuccess=function(){
	$('#'+datagrid.datagridId).datagrid('loaded');
	$("#queryBtn_Filter").removeAttr("disabled");
	$('.editcls').linkbutton({plain:true,iconCls:'icon-edit'});  //给每行后的button加easyui样式
	$('.delcls').linkbutton({plain:true,iconCls:'icon-remove'});
	//行尾button显示或隐藏
${columnsTag.lineTailAuth}
	//根据防问权限控制toolbar button显示或隐藏
${columnsTag.toolbarBtns.buttonAuth}

	//行首菜单button,打开菜单列表
	$.each($("a"),function(index,value){
		var obj = $(this);
		var rowIndex1 = obj.attr("rowIndex");
		if(rowIndex1 != undefined){
			obj.mouseover(function(e){
				var obj = $(this);
				var offset = obj.offset();
				e.preventDefault();
				rowIndex = rowIndex1;
				var selected=$("#list").datagrid('getRows'); //获取所有行集合对象
				if(selected[rowIndex] == null){return;}
				id = selected[rowIndex].id; //index为当前右键行的索引，指向当前行对象
				$('#rightMenuDiv').menu('show', {
					left:offset.left+47,
					top:offset.top-5
				});
			});
		}
	});
};


<#--datagrid.datagridObj.rowStyler = function(index,row){
	/*if (row.listprice>2){*/
	if (index%2==1){
		return 'background-color:#eee;color:#222;'; // return inline style
		// the function can return predefined css class and inline style
		// return {class:'r1', style:{'color:#fff'}};
	}
};-->

//添加右击菜单内容
var id;
var rowIndex;
function onRowContextMenu(e, rowIndex1, rowData){
	e.preventDefault();
	rowIndex = rowIndex1;
	var selected=$("#list").datagrid('getRows'); //获取所有行集合对象
	if(selected[rowIndex] == null){return;}
	id = selected[rowIndex].${templateTable.primaryKey}; //index为当前右键行的索引，指向当前行对象
	$('#rightMenuDiv').menu('show', {
		left:e.pageX,
		top:e.pageY
	});
};




/**
打开AddDialog时，加载默认值
*/
var _defaultValueJOStr = ${columnsTag.defaultValueJOStr}


/**
所有列备份一下，一会隐藏了，可以恢复
*/
var _columnDivArray = new Array();
<#list columnsTag.column4Add as item>
_columnDivArray[_columnDivArray.length] = '#_${item.columnName}_line';
</#list>


